home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / sort2.zip / SORT.MAN < prev    next >
Text File  |  1993-01-04  |  6KB  |  198 lines

  1.  
  2.                                                         3/5/89
  3.  
  4.         SORT -- merge and sort multiple files, by J. W. Rider
  5.  
  6.         SYNTAX:
  7.  
  8.               SORT [options] [<unsorted-file-spec> ... ]
  9.  
  10.         DESCRIPTION:
  11.  
  12.                 This utility is intended to replace the SORT
  13.         function that comes with MS-DOS.  The command syntax is
  14.         upward compatible with the MS-DOS SORT.  In addition,
  15.         this SORT is capable of ignoring the case of alphabetic
  16.         characters, sorting numerically, and sorting files too
  17.         large to be sorted by the MS-DOS SORT.
  18.  
  19.                 Options can be preceded by either "/" (MS-DOS
  20.         standard) or "-" (UNIX standard).  Available options
  21.         include the following two options that are syntax
  22.         compatible with the MSDOS version:
  23.  
  24.                 R  -- reverses the sense of the sort.
  25.  
  26.                 +# -- sorts each line based upon characters
  27.                       beginning in column #.
  28.  
  29.         The following additional options are available:
  30.  
  31.                 +# -- a second number denotes the last column of
  32.                       the key field.  The "+" character for
  33.                       either the first or second number is
  34.                       optional.
  35.  
  36.                 B  -- ignore leading blanks in field.
  37.  
  38.                 C  -- ignore case (i.e., "a" = "A" ).
  39.  
  40.                 D  -- ignore non-alphanumerics in comparisons.
  41.  
  42.                 F  -- use "awk" fields instead of columns in
  43.                       determining key.
  44.  
  45.                 H  -- display a help message instead of sorting
  46.                       input.
  47.  
  48.                 K  -- output only the sort keys, not the whole
  49.                       line (useful for determining what you are
  50.                       actually sorting against).
  51.  
  52.                 N  -- sort lines numerically instead of
  53.                       alphabetically.
  54.  
  55.                 Tc -- Use the character 'c' instead of tabs or
  56.                       spaces to delimit fields when '/F' is
  57.                       effective.  Multiple '/Tc' options can
  58.                       be used.  If you want to include spaces and
  59.                       tabs as field delimiters, use '/T ' with
  60.                       a blank after the switch. (This has the
  61.                       effect of making each individual space or
  62.                       tab define a new field.  Two spaces
  63.  
  64.               Copyright 1988, 1989, by J. W. Rider
  65.  
  66.  
  67.  
  68.  
  69.  
  70.         SORT                      2                     SORT
  71.  
  72.                       together would define a null field between
  73.                       them.)
  74.  
  75.                 U  -- eliminate multiple copies of identical
  76.                       lines.
  77.  
  78.                 If the "unsorted-file-spec" name is missing or is
  79.         "-" then lines are read from standard input.
  80.  
  81.                 Sorted lines are written to standard output.
  82.         This is redirectable under DOS.
  83.  
  84.                 Some files are too large to be sorted in memory
  85.         at one time.  In this case, SORT provides a partial
  86.         ordering that can be improved with subsequent SORT
  87.         efforts.  Here is an example of a "two-stage" sort:
  88.  
  89.            C>SORT BIGFILE | SORT >BIGSORT
  90.            SORT: Output may not be completely sorted.
  91.  
  92.         (The warning comes from the first stage of the sort.  The
  93.         lack of a second warning indicates that the output was
  94.         correctly sorted in the second stage.)
  95.  
  96.         On a relatively slow machine with available memory
  97.         limited to 200K bytes, a two-stage sort was able to
  98.         completely order a 300K byte file in about 10 minutes.
  99.         When memory was freed to 450K, the same file was sorted
  100.         in a single stage in about five minutes.
  101.  
  102.         EXAMPLES:
  103.  
  104.         To sort the contents of "file1" and put the sorted lines
  105.         into "file2":
  106.  
  107.                         SORT file1 >file2
  108.  
  109.         To merge the contents of two files sorted on the second
  110.         comma-delimited field:
  111.  
  112.               SORT -f -t, -2 -3 file1 file2 >file3
  113.  
  114.         To combine all basic program files in the current
  115.         directory, maintaining line number order:
  116.  
  117.                      SORT -n *.bas >outfile
  118.  
  119.         Classically, SORT has been used to reorder the display of
  120.         directory filenames (DIR).  This is accomplished by:
  121.  
  122.                            DIR | SORT
  123.  
  124.         To sort the directory on the first letter of the
  125.         extension, use:
  126.  
  127.                          DIR | SORT -10
  128.  
  129.  
  130.               Copyright 1988, 1989, by J. W. Rider
  131.  
  132.  
  133.  
  134.  
  135.  
  136.         SORT                      3                     SORT
  137.  
  138.         To sort the directory on the size of the file:
  139.  
  140.                          DIR | SORT -13
  141.  
  142.         To sort the directory on the minute that each file was
  143.         lasted changed:
  144.  
  145.                       DIR | SORT -f -t: -2
  146.  
  147.         BUGS:
  148.                 Attempting to overwrite an input file with the
  149.         sorted lines may destroy your data.  Do not use "SORT a b
  150.         >a" or "SORT a b >b".
  151.  
  152.                 Sorting numerically against lines that do not
  153.         contain numbers may yield unexpected results.
  154.  
  155.                 Sorting numerically is limited to values that can
  156.         be expressed as "real" data types within the context of
  157.         the Borland Turbo Pascal (version 5) compiler.
  158.  
  159.                 The original order of lines with the same key
  160.         may not be preserved.  This may have some impact on the
  161.         ability of SORT to find a previous copy of a line in the
  162.         sorting process.
  163.  
  164.                 While this "SORT" is syntax compatible with
  165.         MS-DOS, it is not compatible with an earlier version
  166.         where the output file could be named on the command line
  167.         with the input files.  No data will be lost because of
  168.         the confusion.  However, sorted data will not be saved
  169.         where you expect it to be saved.
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.               Copyright 1988, 1989, by J. W. Rider
  197.  
  198.